﻿using System;
using ASPNETVN.PORTAL.Components.Helpers;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Components.Configuration.Settings;
using ASPNETVN.PORTAL.Components.UI.DataTypes;

namespace ASPNETVN.PORTAL.Modules.DOCUMENT
{
    public partial class Main : PortalModuleControl
    {
        public Main()
        {
            ModuleSettingItem uploadPath = new ModuleSettingItem(new StringDataType("Uploads"));
            uploadPath.Name = "Thư mục upload";
            uploadPath.Description = "Thư mục upload";
            uploadPath.Order = 0;
            this.BaseSettings.Add("UploadPath", uploadPath);
        }
        protected static string GetFilePath(string filepath, string linktype)
        {
            // External link.
            if (linktype.ToUpper() == "EXTERNAL")
            {
                return filepath;
            }
            // Internal link.
            return "~/" + filepath;
        } 

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                gvItem.Columns[gvItem.Columns.Count - 1].Visible = this.IsDeleteable;
                gvItem.Columns[gvItem.Columns.Count - 2].Visible = this.IsEditable;

                this.ModuleTitle.AddUrl = HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, 0, "page=AddEditDocument");
                sdsItem.SelectParameters["ModuleID"].DefaultValue = this.ModuleID.ToString();
                gvItem.DataBind();
            }
        }
    }
}